﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

// NPC.cs
// A non-controllable character who can appear in Areas and can talk to the player.
namespace RTS_RPG
{
    public class NPC
    {
        public static short TALKING_DISTANCE = 100;

        public Texture2D image;
        public Vector2 location;
        // public Vector2 draw_location;
        // public Vector2 text_location;
        public string name;

        private string speech;
        private bool talking;

        public NPC(Texture2D _image, Vector2 _location, string _name, string _speech)
        {
            image = _image;
            location = _location;
            name = _name;
            speech = _speech;
            talking = false;
        }

        public void draw(SpriteBatch spBatch, Area_TextureManager textures)
        {
            spBatch.Draw(image, new Vector2(
                location.X - Area_TextureManager.HALF_CHARACTER_SIZE, 
                location.Y - Area_TextureManager.HALF_CHARACTER_SIZE), Color.White);
            if (talking)
            {   // I eventually wanna use different fonts for different emotions somehow.
                spBatch.DrawString(textures.font, speech, location, Color.Black);
            }
        }

        public void update(Vector2 player_location)
        {
            if (Vector2.Distance(location, player_location) <= TALKING_DISTANCE)
                talking = true;
            else 
                talking = false;
        }
    }
}
